package com.wecommodule.bpm.ext.framework.config;



import com.wecommodule.bpm.ext.framework.filter.CharacterEncodingFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

@Configuration
public class TraceIdFilterConfig {

    /**
     * 注册字符集过滤器
     *
     * @return {@link FilterRegistrationBean}
     */
    @Bean
    public FilterRegistrationBean registerCharsetFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new CharacterEncodingFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setName("CharacterEncodingFilter");
        filterRegistrationBean.setOrder(Integer.MIN_VALUE);
        return filterRegistrationBean;
    }

/*    *//**
     * 过滤器登记bean1  用来集成到中台服务器用的东西
     *
     * @return {@link FilterRegistrationBean}
     *//*
    @Bean
    public FilterRegistrationBean filterRegistrationBean1() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(initCustomFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(Integer.MIN_VALUE+1);
        return filterRegistrationBean;
    }

    *//**
     * 初始化自定义过滤器   给上面过滤器提供的bean
     *
     * @return {@link Filter}
     *//*
    @Bean
    public Filter initCustomFilter() {
        return new TraceIdFilter();
    }*/
}